﻿@model NFine.Domain._03_Entity.Biz.BasicSettingEntity
@{
    ViewBag.Title = "首页广告图";
    Layout = "~/Views/Shared/_Form.cshtml";
}

<link href="~/Content/js/uploadify/uploadify.css" rel="stylesheet" type="text/css" />
<script src="~/Content/js/uploadify/jquery.uploadify.min.js" type="text/javascript"></script>
<link href="~/Content/js/simditor/css/simditor.css" rel="stylesheet" />
<script src="~/Content/js/simditor/js/module.min.js"></script>
<script src="~/Content/js/simditor/js/hotkeys.min.js"></script>
<script src="~/Content/js/simditor/js/uploader.min.js"></script>
<script src="~/Content/js/simditor/js/simditor.min.js"></script>
<style type="text/css">
    /*文本编辑器高度*/
    .simditor .simditor-body, .editor-style {
        min-height: 350px;
    }
</style>
<form id="form1">
      <table class="form" style="width:auto">
            <tr>
                <th class="formTitle">广告主题：</th>
                <td class="formValue"><input type="hidden" id="F_Id" name="F_Id"  value="@Model.F_Id"/><input type="hidden" id="F_AppId" name="F_AppId" value="@Model.F_AppId" />
                     <input type="text" id="F_AppId"  name="F_AppId" value="@Model.F_AppId" class="form-control required" style="width:300px;" />
                </td>
            </tr>
                 <tr>
                    <th class="formTitle" style="padding-bottom:15px">广告图片：</th>
                    <td class="formValue">
                        <input id="file_upload" name="file_upload" type="file">
                        <input id="F_Logo" name="F_Logo" type="hidden" value="@Model.F_Logo">
                        <input id="Old_Logo" name="Old_Logo" type="hidden" value="@Model.F_Logo" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle"></th>
                    <td class="formValue" id="tdImage">
                           <img src="@Model.F_Logo" width="412" height="187" id="pic_view" />
                        @*<p>最佳分辨率为：824px*374px</p>*@
                    </td>
                </tr>
          <tr>
              <th class="formTitle" valign="top" style="padding-top: 5px;">
                  广告内容
              </th>
              <td class="formValue">
                  <textarea id="F_JJ" name="F_JJ" class="form-control required"></textarea>
              </td>
          </tr>
                <tr>
                    <th class="formTitle"></th>
                    <td class="formValue">
                        <input type="button" id="btnSub" class="btn btn-primary" value="设 置" onclick="submitForm()"/>
                    </td>
                </tr>
      </table>
 </form>
<script>
    $(function () {
       var editor = new Simditor({
            textarea: $('#F_JJ'),
            toolbar: ['title', 'bold', 'italic', 'underline', 'strikethrough', 'color', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|', 'link', 'image', 'hr', '|', 'indent', 'outdent'],
            upload: {
                url: '/Biz/Product/EditorUpload', //文件上传的接口地址
                params: null, //键值对,指定文件上传接口的额外参数,上传的时候随文件一起提交
                fileKey: 'fileDataFileName', //服务器端获取文件数据的参数名
                connectionCount: 3,
                leaveConfirm: '正在上传文件'
            }
        });
       editor.Width = 1000;
       editor.setValue('@Html.Raw(Model.F_JJ)');
        $('#file_upload').uploadify({
            'swf': '/Content/js/uploadify/uploadify.swf',  //FLash文件路径
            'buttonText': '浏  览',                                 //按钮文本
            'uploader': '/Messages/Upload',                       //处理文件上传Action
            'queueSizeLimit': 10,                          //队列最多可上传文件数量，默认为999
            'auto': true,                                 //选择文件后是否自动上传，默认为true
            'multi': false,                                 //是否为多选，默认为true
            'removeCompleted': true,                       //是否完成后移除序列，默认为true
            'fileSizeLimit': '10MB',                       //单个文件大小，0为无限制，可接受KB,MB,GB等单位的字符串值
            'fileTypeDesc': 'Image Files',                 //文件描述
            'fileTypeExts': '*.gif; *.jpg; *.png; *.bmp',  //上传的文件后缀过滤器
            'onQueueComplete': function (event, data) {                 //所有队列完成后事件

            },
            'onUploadStart': function (file) {
                $("#file_upload").uploadify("settings", 'formData', { 'folder': 'gg' }); //动态传参数
            },
            'onUploadError': function (event, queueId, fileObj, errorObj) {
               
            },
            'onUploadSuccess': function (file, data, response) {
                var arr = data.split('{');
                $('#pic_view').attr("src", "/UploadFiles/gg/" + arr[0]);
                $("#F_Logo").val("/UploadFiles/gg/" + arr[0]);
                return false;
            }
        });
    });
    function submitForm() {
        if (!$('#form1').formValid()) {
            return false;
        }
        $.submitForm({
            url: "/Messages/SubmitFormBaseSetting?old=" + $("#Old_Logo").val(),
            param: $("#form1").formSerialize(),
            success: function () {
                $.reload();
            }
        });
    }
</script>